#include "CurrentLoop.h"

void Inside_Loop_Init(void)
{
	IdLoop.Kp=144; //Q10
	IdLoop.Ki=470; //Q14
	
	IqLoop.Kp=144;
	IqLoop.Ki=470                                                                                  ;
                      
	IdLoop.OutMax=MAX_AMP;
	IdLoop.OutMin=-MAX_AMP;
	
	IdLoop.Ui = 0;
	IdLoop.Out = 0;	                                        
	
	IdLoop.Ref = 0;
	IdLoop.Fdb = 0;
	IdLoop.Err = 0;
	IdLoop.Up = 0;
	
	IqLoop.OutMax = MAX_AMP;
	IqLoop.OutMin = -MAX_AMP;

	IqLoop.Ui = 0;
	IqLoop.Out = 0;  
	
	IqLoop.Ref = 0;
	IqLoop.Fdb = 0;
	IqLoop.Err = 0;
	IqLoop.Up = 0;
	
	
}

void InsideLoopCalc(void)
{
	
	IdLoop.OutMax=MAX_AMP;
	IdLoop.OutMin=-MAX_AMP;
	
	IqLoop.OutMax=MAX_AMP;
	IqLoop.OutMin=-MAX_AMP;
	
	IdLoop.Ref=SysPara.IdRef;
	
	IdLoop.Fdb=SysPara.IdFilter;
	
	PI_Calc(&IdLoop);
	
	IqLoop.Ref = SpeedLoop.Out;//Q14
	IqLoop.Fdb = SysPara.IqFilter;//Q14
	
	PI_Calc(&IqLoop);
	
}





